package db

import (
	"gorm.io/gorm"
)

// TableRelationship 表示表与表之间的关联关系
type TableRelationship struct {
	gorm.Model
	Name             string `gorm:"type:varchar(255);not null;comment:'关联关系名称'"`
	DatasourceID     uint   `gorm:"not null;comment:'数据源表 ID'"`
	Database         string `gorm:"type:varchar(255);not null;comment:'数据源数据库名称'"`
	SourceTable      string `gorm:"type:varchar(255);not null;comment:'源表名称'"`
	TargetTable      string `gorm:"type:varchar(255);not null;comment:'目标表名称'"`
	RelationshipType string `gorm:"type:varchar(20);not null;comment:'关联关系类型，object 或 array'"`
}

// TableRelationshipField 表示表关联中字段的对应关系
type TableRelationshipField struct {
	gorm.Model
	RelationshipID              uint   `gorm:"not null;comment:'外键关联到 table_relationships 的 ID'"`
	SourceTableField            string `gorm:"type:varchar(255);not null;comment:'源表字段名'"`
	TargetTableField            string `gorm:"type:varchar(255);not null;comment:'目标表字段名'"`
	SourceTargetRelationshipKey string `gorm:"type:varchar(255);not null;comment:'唯一标识字段关系'"`
}
